import { HRDLevels } from "./LevelsConfig";

const { ccclass, property } = cc._decorator;

@ccclass
export default class MainScene extends cc.Component {

    @property(cc.Node)
    nodeScrContent: cc.Node = null;

    @property(cc.Prefab)
    prfLevelCell: cc.Prefab = null;

    onLoad() {
        this.initLevels();
    }

    start() {

    }

    public initLevels() {
        this.nodeScrContent.removeAllChildren();

        let levels = Object.keys(HRDLevels);
        for (let i = 0; i < levels.length; ++i) {
            let key = levels[i];
            let levelName = HRDLevels[key].name;
            let levelCell = cc.instantiate(this.prfLevelCell);
            let cellCtrl = levelCell.getComponent('LevelCell');
            cellCtrl.initCell(key, levelName);
            this.nodeScrContent.addChild(levelCell);
        }
    }
}
